package cn.edu.scau.dropship.mapper;

import cn.edu.scau.dropship.entity.Classification;
import cn.edu.scau.dropship.entity.ClassificationExample;
import java.util.List;
import org.apache.ibatis.annotations.Arg;
import org.apache.ibatis.annotations.ConstructorArgs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ClassificationMapper {
    @SelectProvider(type=ClassificationSqlProvider.class, method="countByExample")
    long countByExample(ClassificationExample example);

    @DeleteProvider(type=ClassificationSqlProvider.class, method="deleteByExample")
    int deleteByExample(ClassificationExample example);

    @Delete({
        "delete from classification",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into classification (id, name)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR})"
    })
    int insert(Classification record);

    @InsertProvider(type=ClassificationSqlProvider.class, method="insertSelective")
    int insertSelective(Classification record);

    @SelectProvider(type=ClassificationSqlProvider.class, method="selectByExample")
    @ConstructorArgs({
        @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="name", javaType=String.class, jdbcType=JdbcType.VARCHAR)
    })
    List<Classification> selectByExample(ClassificationExample example);

    @Select({
        "select",
        "id, name",
        "from classification",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ConstructorArgs({
        @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="name", javaType=String.class, jdbcType=JdbcType.VARCHAR)
    })
    Classification selectByPrimaryKey(Integer id);

    @UpdateProvider(type=ClassificationSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Classification record, @Param("example") ClassificationExample example);

    @UpdateProvider(type=ClassificationSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Classification record, @Param("example") ClassificationExample example);

    @UpdateProvider(type=ClassificationSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Classification record);

    @Update({
        "update classification",
        "set name = #{name,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Classification record);
}